﻿<?php
require_once("dbc.class.php");
class Ajax extends dbc {
	
	public function __construct() {
		parent::__construct();
	}
	
	public function newsletter() {
		$dbc = $this->dbConnect();
		$name = mysqli_real_escape_string($dbc, trim(@$_POST['email']));
		if(@$_POST['mode'] == "newsletter") {
			
			$checkql = "SELECT * FROM newsletter WHERE name='{$name}'";
			$check = $this->query($checkql);
			
			$sql = "INSERT INTO newsletter SET name='{$name}', active='1', vip='0'";
			
			if($var = mysqli_num_rows($check)) {
				echo $var;
			}
			else {
				$data = $this->query($sql);
			}
		}
	}
	
}

$ajax = new Ajax();
$ajax->newsletter(); 

?>